//
//  XQHomeData.swift
//  XQSwiftUIDemo
//
//  Created by WXQ on 2019/11/15.
//  Copyright © 2019 WXQ. All rights reserved.
//

import SwiftUI
import Combine

/// 继承改变
class XQHomeData: ObservableObject {
    
    /// 标明为 publish 属性
    @Published var dataArr = [XQHomeViewCellModel]() {
        didSet {
            print(#function, "值改变了")
            // 发送改变, 通知视图更新
            self.objectWillChange.send()
        }
    }
    
    init(dataArr: [XQHomeViewCellModel] = []) {
        self.dataArr.append(contentsOf: dataArr)
    }
    
}


enum XQHomeViewCellModelPushType {
    case unknow
    case hStack
    case vStack
    case zStack
    case hvzStack
    case label
    case button
    case image
    case textField
    case list
    case slider
    case alert
    case xq_switch
    case webView
}


/// 遵守 Identifiable 协议
struct XQHomeViewCellModel: Identifiable {
    var id = UUID()
    var deleteDisabled = true
    var moveDisabled = true
    var name: String = ""
    var type: XQHomeViewCellModelPushType = .unknow
}

/// 如果不遵守, 那么需要外部 List 要指定 key  字段
/// List(self.dataArr, id: \.xq_id) { item in  your code  }
//struct XQHomeViewCellModel {
//    var xq_id = UUID()
//    var name: String = ""
//}





